在common/header/store下创建actionCreator1
2
3
4
5
6// 创建action的地方
import * as constants from './constants'
export const searchFocus = () => ({
type: constants.SEARCH_FOCUS
});
在common/header/store下创建constants1
2// 一个创建变量映射的地方,相当于actionTypes,只是名称不同而已
export const SEARCH_FOCUS = 'header/SEARCH_FOCUS';
代码优化,common/header/store/index下导出actionCreator和constants1
2
3
4
5import reducer from './reducer';
import * as actionCreator from './actionCreator'
import * as constants from './constants'
export { reducer, actionCreator, constants}
点击Aa实现文件的变化的实现,common/header/index中1
<NavItem className='right' onClick={ props.clickSearchFocus }> Aa { props.inputValue } </NavItem>
1 | const mapStateToProps = (state) => { |
代码目录
效果